import service from './create'

/**
 *
 * @param url {string} 接口地址
 * @param params {Object} 请求参数
 * @param config {Object} 接口请求配置 接口拦截时可获取
 * @param headers {Object} 增加请求头信息
 */
export const getApi = (url: string, params: object = {}, config: object = {}, headers: object = {}): Promise<any> => {
    return service({
        url,
        method: 'get',
        params,
        headers,
        ...config
    })
};

/**
 *
 * @param url {string} 接口地址
 * @param data {Object} 请求参数
 * @param config {Object} 接口请求配置 接口拦截时可获取
 * @param headers {Object} 增加请求头信息
 */
export const postApi = (url: string, data: object = {}, config: object = {}, headers: object = {}): Promise<any> => {
    return service({
        url,
        method: 'post',
        data,
        headers,
        ...config
    })
};

/**
 *
 * @param url {string} 接口地址
 * @param data {Object} 请求参数
 * @param config {Object} 接口请求配置 接口拦截时可获取
 * @param headers {Object} 增加请求头信息
 */
export const putApi = (url: string, data: object = {}, config: object = {}, headers: object = {}): Promise<any> => {
    return service({
        url,
        method: 'put',
        data,
        headers,
        ...config
    })
};

/**
 *
 * @param url {string} 接口地址
 * @param data {Object} 请求参数
 * @param config {Object} 接口请求配置 接口拦截时可获取
 * @param headers {Object} 增加请求头信息
 */
export const deleteApi = (url: string, data: object = {}, config: object = {}, headers: object = {}): Promise<any> => {
    return service({
        url,
        method: 'delete',
        data,
        headers,
        ...config
    })
};